﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace GameProEngine
{
    static class  Tools
    {
        static Texture2D pixel;
        public static void Initialize(GraphicsDeviceManager graph)
        {
            pixel = new Texture2D(graph.GraphicsDevice, 1, 1);
            Color[] col = new Color[1];
            col[0] = Color.White;
            pixel.SetData<Color>(col);
        }
        public static void DrawLine(Vector2 v_start, Vector2 v_end,Color color, float layer, SpriteBatch spriteBatch)
        {
          
            
            float scale =(float) Math.Sqrt((v_end.X - v_start.X) * (v_end.X - v_start.X) + (v_end.Y - v_start.Y) * (v_end.Y - v_start.Y));
            float rot = (float)Math.Atan2(v_end.Y - v_start.Y, v_end.X - v_start.X);
            //spriteBatch.Draw(pixel, new Rectangle((int)v_start.X,(int)v_start.Y,(int) scale, 1), Color.White);
            float ly = 0;
            spriteBatch.Draw(pixel, v_start, null, color, rot, Vector2.Zero,new Vector2(scale, 1), SpriteEffects.None , ly);
            //spriteBatch.Draw(pixel,v_start, new Rectangle(0,0,1,1), Color.White,rot, Vector2.Zero, 500, SpriteEffects.None, 0);
        }
        public static void DrawRect(SpriteBatch sb, Rectangle r)
        {
            Vector2 r1 = new Vector2(r.X,r.Y);
            Vector2 r2 = new Vector2(r.X, r.Y+r.Height);
            Vector2 r3 = new Vector2(r.X+r.Width,r.Y+r.Height);
            Vector2 r4 = new Vector2(r.X+r.Width,r.Y);

            DrawLine(r1, r2, Color.Red, 0, sb);
            DrawLine(r2, r3, Color.Red, 0, sb);
            DrawLine(r3, r4, Color.Red, 0, sb);
            DrawLine(r4, r1, Color.Red, 0, sb);


        }
      /*  public static void DrawRect(SpriteBatch sb, Vector2 posIni, Vector2 posFin)
        {
            Vector2 esq1 = new Vector2(posFin.X, posIni.Y);
            Vector2 esq2 = new Vector2(posIni.Y, posFin.Y);

            DrawLine(posIni, esq1, Color.Red, 0, sb);
            DrawLine(posIni, esq2, Color.Red, 0, sb);
            DrawLine(posFin, esq2, Color.Red, 0, sb);
            DrawLine(posFin, esq1, Color.Red, 0, sb);
        }*/
    }
}
